/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.beans.Statement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author mosta
 */
public class OrderProductDataBase {
    
    private Connection conn;
    private Statement stmt;
    private ResultSet result;
    private PreparedStatement prepStmt;

    public OrderProductDataBase() {
        
        DatabaseConnection connection = new DatabaseConnection();
        conn = connection.startConnection();
    }
    
    public int fillOrderdProduct(OrderProductBean orderProduct)
    {
        int value=0;
        try {
            String sql="insert into order_product"
                    +"(c_id,p_id,quantity)"
                    +"VALUES (?,?,?)";
            prepStmt = conn.prepareStatement(sql);
            prepStmt.setInt(1, orderProduct.getcId());
            prepStmt.setInt(2, orderProduct.getpId());
            prepStmt.setInt(3, orderProduct.getQuantity());
            value = prepStmt.executeUpdate();
        } catch (SQLException ex) {
            Logger.getLogger(OrderProductDataBase.class.getName()).log(Level.SEVERE, null, ex);
        }
        return value;
    }
}
